/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.classloader.mutator;

import moved.org.objectweb.asm.MethodAdapter;
import moved.org.objectweb.asm.MethodVisitor;
import moved.org.objectweb.asm.Opcodes;
import picounit.features.classloader.NullVisitor;

abstract public class MethodMutator extends MethodAdapter implements Opcodes {
	private Method method;

	public MethodMutator() {
		super(NullVisitor.INSTANCE);
	}

	public final MethodVisitor mutate(Method method, MethodVisitor methodVisitor) {
		this.method = method;
		this.mv = methodVisitor;

		return shouldMutate(method) ? this : methodVisitor;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Protected methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@SuppressWarnings("unused")
	protected boolean shouldMutate(Method method) {
		return true;
	}
	
	protected final Method method() {
		return method;
	}
}
